package com.mobsandgeeks.adapters.samples;/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import ohos.agp.components.Attr;
import ohos.agp.components.AttrSet;

/**
 * AttrUtils
 *
 * @since 2021-07-08
 */
public class AttrUtils {
    /**
     * 构造
     */
    private AttrUtils() {
    }

    /**
     * getIntFromAttr
     *
     * @param var0
     * @param var1
     * @param var2
     * @return int
     */
    public static int getIntFromAttr(AttrSet var0, String var1, int var2) {
        int var3 = var2;

        if (var0.getAttr(var1).isPresent() && var0.getAttr(var1).get() != null) {
            var3 = ((Attr) var0.getAttr(var1).get()).getIntegerValue();
        }
        return var3;
    }

    /**
     * getFloatFromAttr
     *
     * @param var0
     * @param var1
     * @param var2
     * @return float
     */
    public static float getFloatFromAttr(AttrSet var0, String var1, float var2) {
        float var3 = var2;

        if (var0.getAttr(var1).isPresent() && var0.getAttr(var1).get() != null) {
            var3 = ((Attr) var0.getAttr(var1).get()).getFloatValue();
        }
        return var3;
    }

    /**
     * getBooleanFromAttr
     *
     * @param var0
     * @param var1
     * @param var2
     * @return boolean
     */
    public static boolean getBooleanFromAttr(AttrSet var0, String var1, boolean var2) {
        boolean var3 = var2;
        if (var0.getAttr(var1).isPresent() && var0.getAttr(var1).get() != null) {
            var3 = ((Attr) var0.getAttr(var1).get()).getBoolValue();
        }
        return var3;
    }

    /**
     * getColorFromAttr
     *
     * @param var0
     * @param var1
     * @param var2
     * @return int
     */
    public static int getColorFromAttr(AttrSet var0, String var1, int var2) {
        int var3 = var2;
        if (var0.getAttr(var1).isPresent() && var0.getAttr(var1).get() != null) {
            var3 = ((Attr) var0.getAttr(var1).get()).getColorValue().getValue();
        }

        return var3;
    }

    /**
     * getDimensionFromAttr
     *
     * @param var0
     * @param var1
     * @param var2
     * @return int
     */
    public static int getDimensionFromAttr(AttrSet var0, String var1, int var2) {
        int var3 = var2;
        if (var0.getAttr(var1).isPresent() && var0.getAttr(var1).get() != null) {
            var3 = ((Attr) var0.getAttr(var1).get()).getDimensionValue();
        }

        return var3;
    }
}